<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Cookie Test</title>
</head>
<body>
<script src="../test/test.js"></script>
<script>
    KISSY.Test.Config.times = 1;
</script>

<h2>Test Data</h2>

<script src="../../build/kissy/kissy-pkg.js"></script>
<script src="cookie.js"></script>

<!-- Test Cases -->
<script>
    var S = KISSY, Cookie = S.Cookie;

    document.cookie = 'test0';
    document.cookie = 'test1=1test0';
    document.cookie = 'test02=2';
    document.cookie = 'xtest0=x';
    document.cookie = 'test3 t   =   ';

    function test_get(test) {
        if(Cookie.get('test0') !== '') test.fail();
        if(Cookie.get('test1') !== '1test0') test.fail();
        if(Cookie.get('test3 t') !== '') test.fail();
        if(Cookie.get('test02') !== '2') test.fail();
        if(Cookie.get('xtest0') !== 'x') test.fail();

        if(Cookie.get('test4') !== undefined) test.fail();

        if(Cookie.get(true) !== undefined) test.fail();
        if(Cookie.get({}) !== undefined) test.fail();
        if(Cookie.get(null) !== undefined) test.fail();
    }

    function test_set(test) {
        Cookie.set('set-test', 'xx');
        if(Cookie.get('set-test') !== 'xx') test.fail();

        Cookie.set('set-test2', 'xx', 0);
        if(Cookie.get('set-test2') !== undefined) test.fail();

        Cookie.set('set-test3', 'xx', new Date(2099, 1, 1), '', '/');
        if(Cookie.get('set-test3') !== 'xx') test.fail();
    }

    function test_remove(test) {
        // path 相同
        Cookie.remove('set-test');
        if(Cookie.get('set-test') != undefined) test.fail();

        // path 不同
        Cookie.remove('set-test3', '', '/');
        if(Cookie.get('set-test3') != undefined) test.fail();
    }

    function test_cookie(test) {
        test.extraMsg = 'document.cookie = "' + document.cookie + '"';
    }
</script>

</body>
</html>
